<?php

namespace App\Api\V1\Models;

use Illuminate\Database\Eloquent\Model;

class Ask extends Model
{
    protected $table = 'ask';
    public $timestamps = false;

    /*
    添加一个提问
    */

    public function addAskItem($request)
    {
           $ds=[
              "user_id"=>'1',
              "ask_type"=>'0',
              "type"=>'1',
    			    "title"=>'主题',
    			    "ask"=>'正文',
    			    "answer"=>'1',
    			    "status"=>'123',
    			    "is_delete"=>'0',
           ];

            $this->user_id = $ds['user_id'];
  	        $this->ask_type = $ds['ask_type'];
  	        $this->type = $ds['type'];
  	        $this->title = $ds['title'];
  	        $this->ask= $ds['ask'];
  	        $this->answer= $ds['answer'];
  	        $this->status = $ds['status'];
	     	    $this->is_delete = $ds['is_delete'];
     	
       if ($this->save()) {
            return $this->toArray();
        }
        return false;
  	}

    /*
    获取问答主题列表
    */

    public function getAskList()
    {
        return $this->get()->toArray();
    }

    /*
    获取一个问答明细
    */

    public function getAskItem()
    {
        return $this->where('ask_id','5')->get()->toArray();
    }

    /*
    删除一条记录
    */

    public function delAskItem()
    {
        return $this->where('ask_id','2')->delete();
    }
}